package com.mymarkdown.app.common.constant;

import com.mymarkdown.app.fx.FxApplication;

import cn.hutool.core.util.StrUtil;

/**
 * @author zenglun
 * @date 2021/12/5 10:25 下午
 * @description: 项目中所有的常量
 */
public class Constant {
	/**
	 * 客户端显示图片的url
	 */
	public final static String BASE_IMAGE_PATH = "http://localhost:"
			+ FxApplication.getSpringBootApplication().getEnvironment().getProperty("server.port")
			+ "/images/showImage?path=%s";

	/**
	 * itext字体文件路径，用于解决中HTML转PDF文乱码问题
	 */
	public final static String CHINES_FONT_PATH = "/Users/zenglun/IdeaProjectss/MyMarkdown/src/main/resources/font.ttf";

	/**
	 * 要解析的转换的元素 (需要将SVG转换为PNG的元素节点)
	 */
	public final static String[] SVG_ARR = new String[] { "div.flowchart", "div.sequence-diagram" };

	/**
	 * base64加密的后的默认菜单
	 */
	public final static String DEFAULT_MENUS_JSON_BASE64 = "W3siaWQiOiIwMDAxIiwidGl0bGUiOiLmlofku7YiLCJpdGVtcyI6W3siaWQiOiIwMDAxXzAwMSIsInRpdGxlIjoi5paw5bu6KENUUkwrTikiLCJiZWFuIjoibmV3Q3JlYXRlRmlsZU1lbnVIYW5kbGVySW1wbCJ9LHsiaWQiOiIwMDAxXzAwMiIsInRpdGxlIjoi5L+d5a2YKENUUkwrUykiLCJiZWFuIjoic2F2ZUZpbGVNZW51SGFuZGxlckltcGwifSx7ImlkIjoiMDAwMV8wMDMiLCJ0aXRsZSI6IuaJk+W8gOaWh+S7tihDVFJMK08pIiwiYmVhbiI6Im9wZW5GaWxlTWVudUhhbmRsZXJJbXBsIn0seyJpZCI6IjAwMDFfMDA1IiwidGl0bGUiOiLlr7zlh7pIVE1MKENUUkwrSCkiLCJiZWFuIjoiZXhwb3J0TWRUb0h0bWxNZW51SGFuZGxlckltcGwifSx7ImlkIjoiMDAwMV8wMDYiLCJ0aXRsZSI6IuWvvOWHulBERihDVFJMK1ApIiwiYmVhbiI6ImV4cG9ydE1kUGRmTWVudUhhbmRsZXJJbXBsIn1dfV0=";

	/**
	 * 要缩放的img class
	 */
	public final static String ZOOM_IMG_CLASS_NAME = "img-transform";

	/**
	 * 用户显示当前操作的文件，格式化文字, %s表示文本信息
	 */
	public final static String HAS_FILE_SHOW_TITLE_FORMAT = "（%s）";

	public final static String NOT_FILE_SHOW_TEXT = String.format(HAS_FILE_SHOW_TITLE_FORMAT, "没有选中任何文件");

	public final static String SAVE_FILE_TEXT = "（%s）";
	/**
	 * 默认等待写入文件时间120秒
	 */
    public static final long DEFAULT_WAIT_WRITER_TIME = 120;
	/**
	 * 默认图标的大小
	 */
	public static final double DEFAULT_LOG_WIDTH = 32;
	public static final double DEFAULT_LOG_HEIGHT = 32;
	/**
	 * 要显示的历史操作数据数量
	 */
	public static final int DEFAULT_HISTORY_NUMBER = 10;

    public interface AllLogsPath{
		String BASE_PATH = StrUtil.isNotBlank(System.getProperty("BASE_CONF_PATH"))
				? System.getProperty("BASE_CONF_PATH")
				: Constant.class.getResource("/").getPath();
		String FILE_LOG_PATH = "file:" + BASE_PATH +  "/icons/file.png";
		String DIR_LOG_PATH = "file:" + BASE_PATH + "/icons/dir.png";
	}

    /**
	 * 存放所有的缓存key
	 */
	public interface AllCacheKey {
		/**
		 * 缓存HTML导出模板的key
		 */
		String HTML_TEMPLATE_CACHE_KEY = "EXPORT_HTML_PRE";
		/**
		 * 获取缓存html模板的cahche对象，用于从CacheManager中获取
		 */
		String CACHE_HTML_TEMPLATE_KEY = "cacheMarkdownHtmlTemplate";
		/**
		 * 保存md文档内容的缓存
		 */
		String SAVE_MD_BODY_CACHE = "saveMarkDownBody";
		/**
		 * 保存
		 */
		String SAVE_SYSTEM_SETTING_CACHE_KEY = "saveSystemSettingCache";

		String RIGHT_TREE_INFOS_CACHE_KEY = "saveRightTreeInfoUI";

	}

	public interface AllFilePath {
		/**
		 * 基础路径 ,如果当前
		 */
		String BASE_PATH = StrUtil.isNotBlank(System.getProperty("BASE_CONF_PATH"))
				? System.getProperty("BASE_CONF_PATH")
				: Constant.class.getResource("/").getPath();
		/**
		 * 构建所有菜单的文件
		 */
		String BUILD_ALL_MENUS_FILE = BASE_PATH + ".menus.json";

		/**
		 * 读取用户最近操作的信息
		 */
		String USER_LATELY_INFO_FILE = BASE_PATH + ".lately_user_info.json";

		/**
		 * 没有保存的md文件内容信息
		 */
		String NOT_SAVE_MD_BODY_FILE = BASE_PATH + ".notSaveMdBody_temp";
		/**
		 * 模板的路径
		 */
		String MD_HTML_TEMPLATE_FILE = BASE_PATH + "template_pre.html";

		/**
		 * 保存转换svg尺量图转换为图片的存储路径
		 */
		String SVG_IMAGE_TEMP_PATH = BASE_PATH + "temp";

		/**
		 * 图标地址
		 */
		String APP_ICON_PATH = BASE_PATH + "logo.png";

		/**
		 * 系统设置配置文件
		 */
		String SYSTEM_SETTING_CONFIG_FILE = BASE_PATH + ".systemSettingInfo.json";

		String RIGHT_TREE_INFO_JSON_FILE = BASE_PATH + ".rightTree.json";
	}

	// 配置到这里

}
